package org.sgs.reddit.bot.json;

import java.util.Collection;

/*
 * GOOD:
 * {
 *   "json": {
 *      "errors": [],
 *      "data": {"modhash": "ALPHANUMERIC",
 *               "cookie": "NUMERIC,DATE,ALPHANUMERIC"}
 *       }
 *  }
 * 
 * BAD:
 * {
 *   "json": {
 *      "errors": [
 *                  ["WRONG_PASSWORD", "invalid password"]
 *                ]
 *     }
 * }
 * 
 */
public class RedditLogin {

  private Json json;

  public RedditLogin() {
    //
  }

  public Json getJson() {
    return json;
  }

  public void setJson(Json json) {
    this.json = json;
  }

  public boolean success() {
    return json.getErrors() != null && json.getErrors().size() == 0;
  }

  public String getModHash() {
    return json.getData().getModhash();
  }

  public String getCookieString() {
    return json.getData().getCookie();
  }

}

class Json {
  private Collection<Collection<String>> errors;
  private Data data;

  public Json() {
    //
  }

  public void setErrors(Collection<Collection<String>> errors) {
    this.errors = errors;
  }

  public Collection<Collection<String>> getErrors() {
    return errors;
  }

  public Data getData() {
    return data;
  }

  public void setData(Data data) {
    this.data = data;
  }
}

class Data {
  private String modhash;
  private String cookie;

  public Data() {
    //
  }

  public String getModhash() {
    return modhash;
  }

  public void setModhash(String modhash) {
    this.modhash = modhash;
  }

  public String getCookie() {
    return cookie;
  }

  public void setCookie(String cookie) {
    this.cookie = cookie;
  }

}
